<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var scoreObject = {
      Tony: {
        Math: 95,
        English: 79,
        Music: 68,
      },
      Simon: {
        Math: 100,
        English: 95,
        Music: 98,
      },
      Annie: {
        Math: 54,
        English: 65,
        Music: 88,
      },
    };

    //编写函数，实现将 JavaScript 对象转化为 JSON 字符串
    function toJSON(jsObj) {
      //your complement
      return JSON.stringify(jsObj);
    }
    console.log(toJSON(scoreObject));

    const jsonObj = '{"Tony":{"Math":95,"English":79,"Music":68},"Simon":{"Math":100,"English":95,"Music":98},"Annie":{"Math":54,"English":65,"Music":88}}'
    console.log(JSON.parse(jsonObj));


    // localStorage.setItem('(haha', '今天挺高兴')
    // sessionStorage.setItem('heihei','nicai')
  </script>
</body>

</html>